import axios from 'axios';
// Actions
const FETCH_LOG_LIST = 'yapi/log/FETCH_LOG_LIST';

// Reducer
const initialState = {
    curdata: {},
    list: [],
    editStatus: false, // 记录编辑页面是否有编辑,
    totalTableList: [],
    catTableList: [],
    count: 0,
    totalCount: 0
};

export default (state = initialState, action) => {
    switch (action.type) {
        case FETCH_LOG_LIST: {
            return {
                ...state,
                totalTableList: action.payload.data.data.list,
                totalCount: action.payload.data.data.count
            };
        }
        default:
            return state;
    }
};

export async function fetchLogList(projecttype) {
    const params = {projecttype: projecttype};
    let result = await axios.get('/api/log/list_with_user', { params: params });
    return {
        type: FETCH_LOG_LIST,
        payload: result
    }
}
